package com.gs.weather.service.impl;

import com.gs.weather.dao.DisasterForecastDao;
import com.gs.weather.entity.DisasterForecast;
import com.gs.weather.service.DisasterForecastService;
import com.gs.weather.utils.HttpUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DisasterForecastServiceImpl implements DisasterForecastService {

    @Autowired
    DisasterForecastDao dao;

    @Override
    public Integer add(DisasterForecast disasterForecast) {
        return dao.add(disasterForecast);
    }

    @Override
    public List<DisasterForecast> queryAll() {
        return dao.queryAll();
    }

    @Override
    public ResponseEntity update(DisasterForecast disasterForecast) {
        if (dao.update(disasterForecast)) {
            return HttpUtils.buildStringResponse("OK", HttpStatus.OK);
        }
        return null;
    }

    @Override
    public ResponseEntity delete(int id) {
        if (dao.delete(id)) {
            return HttpUtils.buildStringResponse("OK", HttpStatus.OK);
        }
        return null;
    }

    @Override
    public Double queryThreshold(String name) {
        return  dao.queryThreshold(name);
    }

}
